<template>
  <div class="contact-page">
    <!-- 页面头部 -->
    <section class="page-header">
      <div class="container">
        <h1 class="title-primary">商家入驻</h1>
        <p class="subtitle">加入我们的平台，开启更广阔的商业合作</p>
      </div>
    </section>

    <!-- 入驻优势 -->
    <section class="advantages section">
      <div class="container">
        <h2 class="title-secondary text-center">入驻优势</h2>
        <div class="advantages-grid">
          <div class="advantage-card card">
            <div class="advantage-icon">
              <el-icon size="48"><TrendCharts /></el-icon>
            </div>
            <h3>品牌曝光</h3>
            <p>获得更多品牌曝光机会，提升知名度</p>
          </div>
          <div class="advantage-card card">
            <div class="advantage-icon">
              <el-icon size="48"><Link /></el-icon>
            </div>
            <h3>精准对接</h3>
            <p>与优质采购商精准对接，提高成交率</p>
          </div>
          <div class="advantage-card card">
            <div class="advantage-icon">
              <el-icon size="48"><DataAnalysis /></el-icon>
            </div>
            <h3>数据支持</h3>
            <p>获得详细的数据分析，优化经营策略</p>
          </div>
          <div class="advantage-card card">
            <div class="advantage-icon">
              <el-icon size="48"><Service /></el-icon>
            </div>
            <h3>专业服务</h3>
            <p>享受专业的平台服务和技术支持</p>
          </div>
        </div>
      </div>
    </section>

    <!-- 入驻申请表单 -->
    <section class="application-form section">
      <div class="container">
        <div class="form-container">
          <div class="form-header">
            <h2 class="title-secondary">入驻申请</h2>
            <p>招商入驻当前仅提供联系客服方式哦~客服微信：HH-188-199，感谢各位理解~</p>
            <!-- <p>请填写以下信息，我们将在24小时内与您联系</p> -->
          </div>
          
          <el-form
            v-if="false"
            ref="formRef"
            :model="form"
            :rules="rules"
            label-width="120px"
            size="large"
            class="application-form-content"
          >
            <div class="form-section">
              <h3>基本信息</h3>
              <el-form-item label="企业名称" prop="companyName">
                <el-input v-model="form.companyName" placeholder="请输入企业名称" />
              </el-form-item>
              
              <el-form-item label="联系人" prop="contactName">
                <el-input v-model="form.contactName" placeholder="请输入联系人姓名" />
              </el-form-item>
              
              <el-form-item label="联系电话" prop="phone">
                <el-input v-model="form.phone" placeholder="请输入联系电话" />
              </el-form-item>
              
              <el-form-item label="邮箱地址" prop="email">
                <el-input v-model="form.email" placeholder="请输入邮箱地址" />
              </el-form-item>
              
              <el-form-item label="微信号" prop="wechat">
                <el-input v-model="form.wechat" placeholder="请输入微信号" />
              </el-form-item>
            </div>

            <div class="form-section">
              <h3>企业信息</h3>
              <el-form-item label="所在地区" prop="location">
                <el-input v-model="form.location" placeholder="请输入所在地区" />
              </el-form-item>
              
              <el-form-item label="成立时间" prop="established">
                <el-date-picker
                  v-model="form.established"
                  type="year"
                  placeholder="请选择成立时间"
                  style="width: 100%"
                />
              </el-form-item>
              
              <el-form-item label="主营类别" prop="category">
                <el-select v-model="form.category" placeholder="请选择主营类别" style="width: 100%">
                  <el-option label="服装" value="服装" />
                  <el-option label="鞋类" value="鞋类" />
                  <el-option label="配饰" value="配饰" />
                  <el-option label="其他" value="其他" />
                </el-select>
              </el-form-item>
              
              <el-form-item label="主营产品" prop="products">
                <el-input
                  v-model="form.products"
                  type="textarea"
                  :rows="3"
                  placeholder="请详细描述主营产品"
                />
              </el-form-item>
              
              <el-form-item label="企业优势" prop="advantages">
                <el-input
                  v-model="form.advantages"
                  type="textarea"
                  :rows="4"
                  placeholder="请描述企业的核心优势和特色"
                />
              </el-form-item>
            </div>

            <div class="form-section">
              <h3>合作信息</h3>
              <el-form-item label="价格区间" prop="priceRange">
                <el-input v-model="form.priceRange" placeholder="如：¥100-500" />
              </el-form-item>
              
              <el-form-item label="最小起订量" prop="minOrder">
                <el-input v-model="form.minOrder" placeholder="如：50件起订" />
              </el-form-item>
              
              <el-form-item label="合作期望" prop="cooperation">
                <el-input
                  v-model="form.cooperation"
                  type="textarea"
                  :rows="3"
                  placeholder="请描述您的合作期望和要求"
                />
              </el-form-item>
            </div>

            <div class="form-actions">
              <el-button size="large" @click="resetForm">重置</el-button>
              <el-button type="primary" size="large" @click="submitForm" :loading="submitting">
                提交申请
              </el-button>
            </div>
          </el-form>
        </div>
      </div>
    </section>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive } from 'vue'
import { ElMessage, type FormInstance, type FormRules } from 'element-plus'
import { TrendCharts, Link, DataAnalysis, Service } from '@element-plus/icons-vue'

const formRef = ref<FormInstance>()
const submitting = ref(false)

const form = reactive({
  companyName: '',
  contactName: '',
  phone: '',
  email: '',
  wechat: '',
  location: '',
  established: '',
  category: '',
  products: '',
  advantages: '',
  priceRange: '',
  minOrder: '',
  cooperation: ''
})

const rules: FormRules = {
  companyName: [
    { required: true, message: '请输入企业名称', trigger: 'blur' }
  ],
  contactName: [
    { required: true, message: '请输入联系人姓名', trigger: 'blur' }
  ],
  phone: [
    { required: true, message: '请输入联系电话', trigger: 'blur' },
    { pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码', trigger: 'blur' }
  ],
  email: [
    { required: true, message: '请输入邮箱地址', trigger: 'blur' },
    { type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur' }
  ],
  location: [
    { required: true, message: '请输入所在地区', trigger: 'blur' }
  ],
  category: [
    { required: true, message: '请选择主营类别', trigger: 'change' }
  ],
  products: [
    { required: true, message: '请描述主营产品', trigger: 'blur' }
  ]
}

const submitForm = async () => {
  if (!formRef.value) return
  
  try {
    await formRef.value.validate()
    submitting.value = true
    
    // 模拟提交过程
    await new Promise(resolve => setTimeout(resolve, 2000))
    
    ElMessage.success('申请提交成功！我们将在24小时内与您联系')
    resetForm()
  } catch (error) {
    ElMessage.error('请检查表单信息是否完整')
  } finally {
    submitting.value = false
  }
}

const resetForm = () => {
  if (!formRef.value) return
  formRef.value.resetFields()
}
</script>

<style scoped>
.contact-page {
  min-height: 100vh;
  background: var(--accent-color);
}

/* 页面头部 */
.page-header {
  background: white;
  padding: 80px 0 60px;
  text-align: center;
}

/* 入驻优势 */
.advantages {
  background: white;
  padding: 80px 0;
}

.advantages-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 30px;
  margin-top: 60px;
}

.advantage-card {
  text-align: center;
  padding: 40px 30px;
}

.advantage-icon {
  color: var(--primary-color);
  margin-bottom: 20px;
}

.advantage-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 15px;
  color: var(--text-primary);
}

.advantage-card p {
  color: var(--text-secondary);
  line-height: 1.6;
}

/* 申请表单 */
.application-form {
  padding: 80px 0;
}

.form-container {
  max-width: 800px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: var(--shadow-light);
  overflow: hidden;
}

.form-header {
  background: var(--gradient-primary);
  color: white;
  padding: 40px;
  text-align: center;
}

.form-header h2 {
  color: white;
  margin-bottom: 10px;
}

.form-header p {
  color: rgba(255, 255, 255, 0.9);
  font-size: 1rem;
}

.application-form-content {
  padding: 40px;
}

.form-section {
  margin-bottom: 40px;
}

.form-section h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary-color);
}

.form-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 40px;
  padding-top: 30px;
  border-top: 1px solid var(--border-color);
}

/* 工具类 */
.text-center {
  text-align: center;
}

/* 响应式设计 */
@media (max-width: 768px) {
  .advantages-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  
  .form-container {
    margin: 0 20px;
  }
  
  .application-form-content {
    padding: 30px 20px;
  }
  
  .form-actions {
    flex-direction: column;
    align-items: center;
  }
}
</style>
